﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace UCS.ArtificialInteligence.AI
{
    public class DepthList<T> : IAIList<T>
    {
        #region Private Members

        private Stack<T> _stack;

        #endregion

        #region Constructors

        public DepthList()
        {
            _stack = new Stack<T>();
        }

        #endregion

        #region Public Methods

        public void Add(T obj)
        {
            _stack.Push(obj);
        }

        public T Remove()
        {
            try
            {
                return _stack.Pop();
            }
            catch (InvalidOperationException)
            {
                return default(T);
            }
        }

        #endregion
    }
}
